#include <QPainter>
#include <QPaintEvent>
#include <QTimer>
#include <QBitmap>
#include <QColor>
#include <QTableWidget>
#include <QPixmap>
#include <QImage>
#include <QPicture>

#include "mydisplaywidget.h"
//#define DARK1 (1,92,101,0)

MyDisplayWidget::MyDisplayWidget(QWidget *parent) :
    QWidget(parent)
{

        //LanguageSetting::tr_free;
    //默认设置
    this->fiberDisplayMode = DisplayXY;
    this->adjust_mode = 0;
    //透明背景颜色
    this->bgLGradient = QLinearGradient();
    this->bgColorTrans = QColor(2,142,155,0);
    //this->bgColorTrans = Qt::lightGray;
    this->gridColorDark = QColor(30,109,116,255);
    this->gridColorLight = QColor(2,142,155,255);
    this->bgColorCovered = QColor(53,192,205,255);

    //this->labelBgColor1 = QColor(94,196,205,200);
    this->labelBgColor1 = QColor(196,205,94,200);
    this->labelTextColor1 = Qt::darkCyan;
    this->lineColorDark = Qt::darkGray;
    this->lineColorLight = Qt::darkGray;

    db_currentCount = 320;
    db_currentModel = DB_NONE;
    my_bgTransparent = false;

}
void MyDisplayWidget::setFiberData(qreal sm, qreal mm)
{
    this->sm = sm;
    this->mm = mm;
}
void MyDisplayWidget::setMeltDoneInfo( )
{
    this->cover         = (::random()%10) * 0.1;
    this->fiberCore     = (::random()%10) * 0.1;
    this->cutAngleLeft  = (::random()%10) * 0.1;
    this->cutAngleRight = (::random()%10) * 0.1;
    this->fiberAngle    = (::random()%10) * 0.1;
    this->estimatedLoss = (::random()%10) * 0.01;
}

void MyDisplayWidget::setCaliberateInfo()
{    
    //this->dataProvider->cliberate_process();
    this->dataProvider->getCaliberationInfo(caliberation_info);
}

void MyDisplayWidget::getBatVal()
{
}

void MyDisplayWidget::setHiddenFunc(int val)
{
    adjust_mode += val;
    qDebug("adjust_mod x set to %d",adjust_mode);
}

void MyDisplayWidget::setAdjMode()
{
    adjust_mode++;
    if(adjust_mode > 1) adjust_mode = 0;
    qDebug("adjust_mod x set to %d",adjust_mode);
}

int MyDisplayWidget::getAdjMode()
{
    if(adjust_mode == 330) return 8;
    else return adjust_mode%2;
}

void MyDisplayWidget::setMinBatVal()
{
}

void MyDisplayWidget::setMaxBatVal()
{
}

void MyDisplayWidget::paintEvent(QPaintEvent *event)
{
    int      info[30];
    int      pos_center;
    QString  strMsg;
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing,true);
    //设置透明备用办法

//    painter.setRenderHint(QPainter::Antialiasing,false);
//    painter.setCompositionMode( QPainter::CompositionMode_Clear );
//    painter.fillRect(0,0,this->width(),this->height(), Qt::SolidPattern );

    QPalette pal = palette();
    pal.setColor(QPalette::Background, this->bgColorTrans);
    setPalette(pal);
    qreal rectW = this->width();
    qreal rectH = this->height();


    if(this->fiberDisplayMode==DisplayBlock)
    {
        //painter.fillRect(this->rect(),this->bgColorTrans);
        QPixmap pixmap(":/new/prefix1/bg.jpg");
        painter.drawPixmap(0,0,this->width(),this->height(),pixmap);
        painter.setPen(QPen(this->lineColorDark, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));

        painter.drawLine(0,1,rectW,1);
        painter.drawLine(0,rectH-1,rectW,rectH-1);

        QRect rectHVlabel(480,300,640,360);
        QFont labelFont;
        labelFont.setPixelSize(16);

        int f_version = this->dataProvider->GetFusionReg(rVERSION);
        int f_mhid0   = this->dataProvider->GetFusionReg(rMHID0);
        int f_mhid1   = this->dataProvider->GetFusionReg(rMHID1);
        int f_prid    = this->dataProvider->getIniItemVal("ProductID");

        QString t_str;

        painter.setPen(QPen(labelTextColor1 , 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        painter.setFont(labelFont);

        //! 带有进度条的button 语言设置 lbs-2017/4/26
        t_str.append( dis_hardwareV +":" + QString().setNum( int ( f_version >> 16)) + "." + QString().setNum(int ((f_version&0xff00) >> 8) ) + "." + QString().setNum(int(f_version&0xff)) + "\n"
                + dis_softwareV +":" + QString().setNum( VERSION_S2) + "." + QString().setNum(VERSION_S1)  + "." + QString().setNum(VERSION_S0) + "\n"
                + dis_equipmentNumber + ":" + QString().setNum(int (f_prid))); // + (f_mhid0^f_mhid1)*1e6

        painter.drawText(rectHVlabel,Qt::AlignLeft,t_str );
    }
    else if(this->fiberDisplayMode==DisplayBar)
    {
        QPixmap pixmap;
        if( my_bgTransparent )
        {
            pixmap = QPixmap(":/new/prefix1/bar_tr.jpg");

        }else {
            pixmap = QPixmap(":/new/prefix1/bar.jpg");
        }

         painter.drawPixmap(0,0,this->width(),this->height(),pixmap);

    }
    else if(this->fiberDisplayMode==DisplayDetail){
        painter.setPen(QPen(lineColorDark, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        painter.drawLine(0,1,rectW,1);
        painter.setPen(QPen(lineColorLight, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        painter.drawLine(0,rectH-1,rectW,rectH-1);
        painter.setPen(QPen(this->labelTextColor1, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        //painter.drawLine(0,rectH/2,rectW,rectH/2);
        //painter.drawLine(rectW/2,0,rectW/2,rectH);

        QRect rectXlabel(10,20,40,40);
        painter.fillRect(10+1,20+1,40-2,40-2,QBrush(this->labelBgColor1));
        painter.drawRoundedRect(rectXlabel,5,5);

        QRect rectYlabel(10,rectH-20-40,40,40);
        painter.fillRect(10+1,rectH-20-40+1,40-2,40-2,QBrush(this->labelBgColor1));
        painter.drawRoundedRect(rectYlabel,5,5);
        painter.setPen(QPen(this->labelTextColor1,2));

        QFont labelFont;
        labelFont.setPixelSize(30);
        painter.setFont(labelFont);
        painter.drawText(rectXlabel,Qt::AlignCenter,"X");
        painter.drawText(rectYlabel,Qt::AlignCenter,"Y");

        QRect rectSMLabel(10,rectH/2-18,50,36);
        painter.fillRect(10+1,rectH/2-18+1,50-2,36-2,QBrush(this->labelBgColor1));
        painter.drawRoundedRect(rectSMLabel,5,5);

        QRect rectMMLabel(rectW-10-50,rectH/2-18,50,36);
        painter.fillRect(rectW-10-50+1,rectH/2-18+1,50-2,36-2,QBrush(this->labelBgColor1));
        painter.drawRoundedRect(rectMMLabel,5,5);

        labelFont.setPixelSize(15);
        painter.setFont(labelFont);

        if((this->dataProvider->getIniItemVal("ParamSel")) == 0)
        {
            painter.drawText(rectSMLabel,Qt::AlignCenter,"SM");
            painter.drawText(rectMMLabel,Qt::AlignCenter,"SM");
        }
        else
        {
            painter.drawText(rectSMLabel,Qt::AlignCenter,"MM");
            painter.drawText(rectMMLabel,Qt::AlignCenter,"MM");
        }

        pos_center = this->dataProvider->getIniItemVal("MeltPosition");
        QRect rectSMValue(pos_center-10-50,rectH/2-18,50,36);
        painter.fillRect(pos_center-10-50+1,rectH/2-18+1,50-2,36-2,QBrush(this->labelBgColor1));
        painter.drawRoundedRect(rectSMValue,5,5);

        QRect rectMMValue(pos_center+10,rectH/2-18,50,36);
        painter.fillRect(pos_center+10+1,rectH/2-18+1,50-2,36-2,QBrush(this->labelBgColor1));
        painter.drawRoundedRect(rectMMValue,5,5);

        labelFont.setPixelSize(15);
        painter.setFont(labelFont);

        this->dataProvider->GetJointInfo(info);
        /*
        joint_info[2] = m3; // core l
        joint_info[3] = m4; // core r
        joint_info[4] = m1; // diam l
        joint_info[5] = m2; // diam r
        joint_info[6] = m5; // face l
        joint_info[7] = m6; // face r
        */
        cutAngleLeft  = (info[6] > info[16])?info[6]:info[16];
        cutAngleRight = (info[7] > info[17])?info[7]:info[17];
        fiberDiam     = info[5] + info[15];
        qDebug("cutAngleLeft=%f cutAngleRight=%f fiberDiam=%f",cutAngleLeft,cutAngleRight,fiberDiam);

        QString A1,A2;
        //A1.sprintf("%.2f",cutAngleLeft/10);
        A1 = QString().sprintf("%.2f",cutAngleLeft/10) + "°";
        //A2.sprintf("%.2f",cutAngleRight/10);
        A2 = QString().sprintf("%.2f",cutAngleRight/10) + "°";
        painter.drawText(rectSMValue,Qt::AlignCenter,A1);
        painter.drawText(rectMMValue,Qt::AlignCenter,A2);

        QRect rectGPValue(pos_center,rectH-28,50,36);
        painter.fillRect(pos_center+1,rectH-27,48,34,QBrush(this->labelBgColor1));

        painter.drawRoundedRect(rectGPValue,5,5);
        int caliberate_edge = this->dataProvider->GetFusionReg(rCALIB_EDG0);
        int gap0 = caliberate_edge&0xffff;
        int gap1 = (caliberate_edge&0xffff0000) >> 16;
        int gapshow = abs(gap1 - gap0);

        QString Gs;
        Gs.sprintf("%d",gapshow);
        painter.drawText(rectGPValue,Qt::AlignCenter,Gs);
    }
    else if(this->fiberDisplayMode==DisplayXY)
    {
        painter.setPen(QPen(lineColorDark, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        painter.drawLine(0,1,rectW,1);
        painter.setPen(QPen(lineColorLight, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        painter.drawLine(0,rectH-1,rectW,rectH-1);
        painter.setPen(QPen(this->labelTextColor1, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        //painter.drawLine(0,rectH/2,rectW,rectH/2);
        //painter.drawLine(rectW/2,0,rectW/2,rectH);

        QRect rectXlabel(10,20,40,40);
        painter.fillRect(10+1,20+1,40-2,40-2,QBrush(this->labelBgColor1));
        painter.drawRoundedRect(rectXlabel,5,5);

        QRect rectYlabel(10,rectH-20-40,40,40);
        painter.fillRect(10+1,rectH-20-40+1,40-2,40-2,QBrush(this->labelBgColor1));
        painter.drawRoundedRect(rectYlabel,5,5);
        painter.setPen(QPen(this->labelTextColor1,2));

        QFont labelFont;
        labelFont.setPixelSize(30);
        painter.setFont(labelFont);
        painter.drawText(rectXlabel,Qt::AlignCenter,"X");
        painter.drawText(rectYlabel,Qt::AlignCenter,"Y");
    }

    else if(this->fiberDisplayMode==DisplayX)
    {
        painter.setPen(QPen(lineColorDark, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        painter.drawLine(0,1,rectW,1);
        painter.setPen(QPen(lineColorLight, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        painter.drawLine(0,rectH-1,rectW,rectH-1);
        painter.setPen(QPen(this->labelTextColor1, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        //painter.drawLine(0,rectH/2,rectW,rectH/2);
        //painter.drawLine(rectW/2,0,rectW/2,rectH);

        QRect rectXlabel(10,20,40,40);
        painter.fillRect(10+1,20+1,40-2,40-2,QBrush(this->labelBgColor1));
        painter.drawRoundedRect(rectXlabel,5,5);

        QFont labelFont;
        labelFont.setPixelSize(30);
        painter.setFont(labelFont);
        painter.drawText(rectXlabel,Qt::AlignCenter,"X");
    }
    else if(this->fiberDisplayMode==DisplayY)
    {
        painter.setPen(QPen(lineColorDark, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        painter.drawLine(0,1,rectW,1);
        painter.setPen(QPen(lineColorLight, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        painter.drawLine(0,rectH-1,rectW,rectH-1);
        painter.setPen(QPen(this->labelTextColor1, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        //painter.drawLine(0,rectH/2,rectW,rectH/2);
        //painter.drawLine(rectW/2,0,rectW/2,rectH);

        QRect rectYlabel(10,rectH-20-40,40,40);
        painter.fillRect(10+1,rectH-20-40+1,40-2,40-2,QBrush(this->labelBgColor1));
        painter.drawRoundedRect(rectYlabel,5,5);
        painter.setPen(QPen(this->labelTextColor1,2));

        QFont labelFont;
        labelFont.setPixelSize(30);
        painter.setFont(labelFont);
        painter.drawText(rectYlabel,Qt::AlignCenter,"Y");
    }
    else if(this->fiberDisplayMode == DisplayDebug)
    {

        const int unitWidth  = rectW/9;
        const int unitHeight = rectW/32;

        int x = rectW - 8*unitWidth;
        int y = (15*rectH)/32 - unitHeight;

        if(adjust_mode == 330){
            AdjustString = "亮度调节";
        }
        else if(adjust_mode == 1){
            AdjustString = "间隙调节";
        }
        else {
            AdjustString = "辅助调节";
        }

        QPen pen(Qt::black,2);
        QBrush blueBG(QColor(0,150,255,200));
        QBrush grayBG(QColor(0,204,64,220));
        QBrush yellBG(QColor(0,204,24,24));
        painter.setPen(pen);
        painter.setBrush(yellBG);

        QRect rect0(rectW/2 - 60,unitHeight,120,unitHeight);
        painter.drawRect(rect0);
        painter.drawText(rect0,Qt::AlignCenter,AdjustString);

        QRect rect1(x,y,unitWidth,unitHeight);
        painter.setBrush(blueBG);
        painter.drawRect(rect1);
        painter.drawText(rect1,Qt::AlignCenter,RightUpEdgePosStr);

        x+= 3*unitWidth;
        QRect rectj(x,y,unitWidth,unitHeight);
        painter.setBrush(grayBG);
        painter.drawRect(rectj);
        painter.drawText(rectj,Qt::AlignCenter,CamXLightStr);
        //
        x+= 3*unitWidth;
        QRect rect2(x,y,unitWidth,unitHeight);
        painter.setBrush(blueBG);
        painter.drawRect(rect2);
        painter.drawText(rect2,Qt::AlignCenter,LeftUpEdgePosStr);

        y+= rectH/2;
        QRect rect3(x,y,unitWidth,unitHeight);
        painter.setBrush(blueBG);
        painter.drawRect(rect3);
        painter.drawText(rect3,Qt::AlignCenter,LeftDownEdgePosStr);
        //
        x-= 3*unitWidth;
        QRect rectk(x,y,unitWidth,unitHeight);
        painter.setBrush(grayBG);
        painter.drawRect(rectk);
        painter.drawText(rectk,Qt::AlignCenter,CamYLightStr);

        x-= 3*unitWidth;
        QRect rect4(x,y,unitWidth,unitHeight);
        painter.setBrush(blueBG);
        painter.drawRect(rect4);
        painter.drawText(rect4,Qt::AlignCenter,RightDownEdgePosStr);

        painter.setPen(QPen(Qt::darkYellow, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));

        int S1 = this->dataProvider->getIniItemVal("AuxLineb");
        int S2 = this->dataProvider->getIniItemVal("AuxWidth");
        if(S1 == 0) S1 = 50;
        if(S2 == 0) S2 = 90;

        painter.drawLine(0,S1,rectW,S1);
        painter.drawLine(0,S1+S2,rectW,S1+S2);
        painter.drawLine(0,380-S1-S2,rectW,380-S1-S2);
        painter.drawLine(0,380-S1,rectW,380-S1);

        painter.setPen(QPen(this->labelTextColor1, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        painter.drawLine(0,rectH/2,rectW,rectH/2);
        painter.drawLine(rectW/2,0,rectW/2,rectH);
        //add eyeline --lbs
        painter.setPen(QPen(Qt::red, 1));
        if ( db_currentModel == DB_LEFT){
            if( db_currentCount <= 0)
            {
                db_currentCount = 0;
            }else{
               db_currentCount -= 4;
            }

        }else if ( db_currentModel == DB_RIGHT){
            if( db_currentCount >=rectW)
            {
                db_currentCount = rectW;
            }else{
               db_currentCount += 4;
                painter.drawLine(db_currentCount,0,db_currentCount,rectH);
            }
        }else if( db_currentModel == DB_NONE){
            db_currentCount = rectW/2;
        }
        db_currentModel = DB_STOP;
        painter.drawLine(db_currentCount,0,db_currentCount,rectH);
    }
    else if(this->fiberDisplayMode==DisplayDiscargeDone)
    {
        const int unitWidth = 150;
        const int unitHeight = 30;

        int x = rectW/2-unitWidth;
        int y = 3*rectH/4-unitHeight*2;

        QPen pen(Qt::black,2);
        QBrush blueBG(QColor(50,50,255,200));
        QBrush greenBG(QColor(50,255,50,200));
        QBrush redBG(QColor(255,50,50,200));
        QBrush grayBG(QColor(255,204,64,220));
        painter.setPen(pen);

        if((caliberation_info[4] & 0xf) == 0){
            painter.setBrush(blueBG);
            strMsg = dis_dischargeNormal;
        }        
        else if((caliberation_info[4] & 0xc) == 0){
            if((caliberation_info[4] & 0x3) == 0x1)
            {
                painter.setBrush(redBG);
                strMsg = dis_dischargeTooStrong;;
            }
            else if((caliberation_info[4] & 0x3) == 0x2){
                painter.setBrush(redBG);
                strMsg = dis_dischargeTooWeak;
            }
        }
        else if((caliberation_info[4] & 0x3) == 0){
            if((caliberation_info[4] & 0xc) == 0x8)
            {
                painter.setBrush(redBG);
                strMsg = dis_fromLeft;
            }
            else if((caliberation_info[4] & 0xc) == 0x4){
                painter.setBrush(redBG);
                strMsg = dis_fromRight;
            }
        }
        else {
            painter.setBrush(redBG);
            strMsg = dis_dischargeAnomaly;
        }

        QRect rect0(x,y,unitWidth*2,unitHeight + 5);
        painter.drawRect(rect0);
        painter.drawText(rect0,Qt::AlignCenter,strMsg);

        painter.setBrush(greenBG);
        y+= (unitHeight + 5);
        QRect rect1(x,y,unitWidth,unitHeight);
        painter.drawRect(rect1);
        painter.drawText(rect1,Qt::AlignCenter,dis_positionAdjustment);
        //
        x+=unitWidth;
        QRect rect2(x,y,unitWidth,unitHeight);
        painter.drawRect(rect2);
        painter.drawText(rect2,Qt::AlignCenter,dis_intensityAdjustment);
        //
        x-=unitWidth;
        y+=unitHeight;
        strMsg.sprintf("%d -> %d",caliberation_info[2],caliberation_info[3]);
        painter.setBrush(grayBG);
        QRect rect3(x,y,unitWidth,unitHeight);
        painter.drawRect(rect3);
        painter.drawText(rect3,Qt::AlignCenter,strMsg);
        //
        x+=unitWidth;
        strMsg.sprintf("%d -> %d",caliberation_info[0],caliberation_info[1]);
        QRect rect4(x,y,unitWidth,unitHeight);
        painter.drawRect(rect4);
        painter.drawText(rect4,Qt::AlignCenter,strMsg);

        painter.setBrush(blueBG);
        x-=unitWidth;
        y+=unitHeight;
        QRect rect5(x,y,unitWidth*2,unitHeight);
        painter.drawRect(rect5);

        strMsg = dis_dischargeNormal;
        painter.drawText(rect5,Qt::AlignCenter,dis_confirm);

    }
    else if(this->fiberDisplayMode==DisplayRemind)
    {
        QPen pen(Qt::black,2);

        if( my_alarmEnable )
        {
            pen.setColor(Qt::red);
        }

        QBrush blueBG(QColor(0,150,255,200));
        QBrush grayBG(QColor(255,204,64,220));
        painter.setPen(pen);
        painter.setBrush(blueBG);

        /*if(this->dataProvider->GetFusionReg(rVIEW_XY) == 0){
            painter.drawLine(0,rectH/2,rectW,rectH/2);
        }*/

        QRect rect(rectW/2-150,rectH/2-100,300,20);
        painter.drawRect(rect);

        strMsg = dis_dischargeNormal;
        painter.drawText(rect,Qt::AlignCenter,dis_prompt);

        painter.setBrush(grayBG);
        QRect rect2(rectW/2-150,rectH/2-100+20,300,60);
        painter.drawRect(rect2);
        painter.drawText(rect2,Qt::AlignCenter,this->RemindMsg);

    }
}


void MyDisplayWidget::ShowAuxPos()
{
    if(this->fiberDisplayMode == DisplayDebug)
    {
        this->dataProvider->setMeltState(MeltDebug);
    }
}

void MyDisplayWidget::getAuxPos()
{
    this->dataProvider->Fiber_edge_x(&FiberLeftUpEdgePos,&FiberRightUpEdgePos);
    this->dataProvider->Fiber_edge_y(&FiberLeftDownEdgePos,&FiberRightDownEdgePos);
    this->dataProvider->Fiber_bright(&FiberCamYBright,&FiberCamXBright);
}

void MyDisplayWidget::SetAuxPosString()
{
    LeftUpEdgePosStr.sprintf("%d",FiberLeftUpEdgePos);
    LeftDownEdgePosStr.sprintf("%d",FiberLeftDownEdgePos);
    RightUpEdgePosStr.sprintf("%d",FiberRightUpEdgePos);
    RightDownEdgePosStr.sprintf("%d",FiberRightDownEdgePos);
    CamXLightStr.sprintf("%d",FiberCamXBright);
    CamYLightStr.sprintf("%d",FiberCamYBright);
}

void MyDisplayWidget::setDataProvider(DataProvider* dp)
{
    this->dataProvider = dp;
}

void MyDisplayWidget::setDisplayMode(FiberDisplayMode mode)
{

    this->fiberDisplayMode = mode;
}

void MyDisplayWidget::setRemindMsg(QString msg ,bool alarmEnable)
{
    this->RemindMsg = msg;
    my_alarmEnable = alarmEnable;
}

QString MyDisplayWidget::getRemindMSg()
{
    return this->RemindMsg;
}

//! 刷新该类的语言 lbs-2017/4/26
void MyDisplayWidget::setLanguageTr(QStringList strTrList)
{
    if( strTrList.length() >= 13 ){
        dis_hardwareV = strTrList[0];
        dis_softwareV = strTrList[1];
        dis_equipmentNumber = strTrList[2];
        dis_dischargeNormal  = strTrList[3];
        dis_dischargeTooStrong = strTrList[4];
        dis_dischargeTooWeak = strTrList[5];
        dis_fromLeft = strTrList[6];
        dis_fromRight = strTrList[7];
        dis_dischargeAnomaly = strTrList[8];
        dis_positionAdjustment = strTrList[9];
        dis_intensityAdjustment = strTrList[10];
        dis_confirm = strTrList[11];
        dis_prompt = strTrList[12];
    }
}

void MyDisplayWidget::setDBKey(DBKEY direction)
{
    db_currentModel = direction;
}

void MyDisplayWidget::setBGTransparent(bool enable)
{
    my_bgTransparent = enable;
}

